<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
</head>
<body>
    总量:<span id="demo1"></span>
    书的id:<span id="demo2"></span>
    书名:<span id="demo3"></span>
    余量:<span id="demo4"></span>
    价格:<span id="demo5"></span>
    书的状态:<span id="demo6"></span>
    类型:<span id="demo7"></span>
    作者:<span id="demo8"></span>
    <button id="lend" type="button">借阅</button>
    <script>
        var url = decodeURI(window.location.href).split('=');
        alert(url[1]);
        axios.post(
        'http://yuntenglibrary.natapp1.cc/searchbook', {
            name: url[1]
            }).then(response => {
            console.log(response)
            document.getElementById("demo1").innerHTML = response.data[0].bfullnumber
            document.getElementById("demo2").innerHTML = response.data[0].bid
            document.getElementById("demo3").innerHTML = response.data[0].bname
            document.getElementById("demo4").innerHTML = response.data[0].bnumber
            document.getElementById("demo5").innerHTML = response.data[0].bprice
            document.getElementById("demo6").innerHTML = response.data[0].bstatus
            document.getElementById("demo7").innerHTML = response.data[0].btype
            document.getElementById("demo8").innerHTML = response.data[0].bwriter
            var lend = document.getElementById("lend")
            lend.onclick = function(){
                if (response.data[0].bstatus == "不可借阅") {
                    alert("已借出")
                }
                else{
                    alert("借阅成功")
                }
            }
    })
    </script>
</body>
</html>